<?php
// *** Tangra (Application Framework and Tools for PHP)
// $Id$
//


require_once(TANGRA_MAIN_DIR.'grids/grid_ctrl.class.php');
require_once(TANGRA_MAIN_DIR.'exceptions/tangra_module_exception.class.php');

require_once($WSC->get_site_inc_dir().'modules/ajax_ctrl/ajax_ctrl.class.php');


abstract class Ajax_Grid_Ctrl extends Ajax_Ctrl {
	private $grid_ctrl;


	protected function init() {
		$this->_create_grid_ctrl();
	}


	public function get_grid_ctrl() {
		return $this->grid_ctrl;
	}


	public function query_grid_ctrl() {
		return $this->grid_ctrl;
	}


	protected function _create_grid_ctrl() {
		$grid_ctrl = $this->create_grid_ctrl();
		if ($grid_ctrl instanceof Grid_Ctrl) {
			$this->grid_ctrl = $grid_ctrl;
		} else {
			throw new Tangra_Module_Exception('create_grid_ctrl returned object that is not Grid_Ctrl.');
		}
	}


	abstract protected function create_grid_ctrl();
}
